﻿@model Occupie.Models.Student

@if (Model.Projects.Count == 0)
{
    <p>Все още не си добавил проекти!</p>
}
else
{
    for (int i = 0; i < Model.Projects.Count; i++)
    {
        if (Model.Projects[i] != null)
        {
    <div id="project@(i)" class="project-item">
        <div class="editor-label">
            @Html.LabelFor(model => model.Projects[i].Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Projects[i].Name)
            <br />
            @Html.ValidationMessageFor(model => model.Projects[i].Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Projects[i].Description)
        </div>
        <div class="editor-multiline-field">
            @Html.EditorFor(model => model.Projects[i].Description)
            <br />
            @Html.ValidationMessageFor(model => model.Projects[i].Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Projects[i].Link)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Projects[i].Link)
            <br />
            @Html.ValidationMessageFor(model => model.Projects[i].Link)
        </div>

        <div class="dialog" id="delProjDialog" style="display: none;"></div>

        <div class="del-link">
            @Ajax.ActionLink("Изтрий", "DeleteProject", "Project", new { projId = Model.Projects[i].ProjectId, listId = i }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "delProjDialog", InsertionMode = InsertionMode.Replace, OnSuccess = "openDelProjectPopup()" })<br />
        </div>
    </div>
            if ((i + 1) % 3 == 0)
            {
                <div style="clear: both"></div>
                <hr class="full-hr" />
            }
        }
    }
}

<script>
    $(document).ready(function () {
        $("#delProjDialog").dialog(
            {
                autoOpen: false,
                width: 300,
                height: 'auto',
                modal: true,
            }
        );
    });
    function openDelProjectPopup() {
        $("#delProjDialog").dialog().dialog("open");
    }
</script>
